import { AxiosResponse } from "axios";
import { HSExtendInterface } from "../utils/request";
import { dapingApi } from "../utils/request";
import { InPlanDevoce } from "@/types/APSData";
/** 设备数据类型 */
export interface InDeviceSync {
  id: string;
  name?: string;
  "device_id": string;
  "type_id": string;
  "type_name": string;
  "jitai_uid": string;
  "jitai_code": string;
  "jitai_name": string;
  "jitai_xinghao": string;
  "work_center": string;
  "exit_code": string;
  "entry_date": string;
  "zichan_code": string;
  "install_position": string;
  "yunxing_status": string;
  "remark": string;
  "factory_id": string;
}
/** 获取甘特图设备列表 */
export const getExtendList = (dataObj: Object): Promise<AxiosResponse<InDeviceSync[]>> =>
  HSExtendInterface({
    url: "/api/dataSyncex",
    method: "post",
    data: {
      ...dataObj,
    },
  });
/** 指标类型 */
export type InType = "正品率" | "产量对比" | "合格率" | "超胶量" | "发货量" | "工厂损益" | "订单损益" | "客户损益" | "入库数" | "异常数";
export interface InHESData {
  Group: string;
  Amount?: string;
  CustomerNo?: string;
  /** 客户名称 */
  sCustomerName?: string;
  Day?: string;
  Week?: string;
  /** 订单号 */
  sOrderNo?: string;
  /** 流转卡号 */
  sCardNo?: string;
  /** 工序名称 */
  sWorkingProcedureName?: string;
  /** 机型 */
  sEquipmentModelName?: string;
  /** 机台  */
  sEquipmentName?: string;
  /** 产量 */
  nTrackQty?: number;
  /** 匹数 */
  nTrackQtyEx?: number;
  /**产出时间 */
  tTrackTime?: string;
  /** 产量 */
  nZHTrackQty?: number;
}
/**(获取指标数据) 正品率/产量对比/合格率/超胶量/发货量
 * @param { Type } 指标类型
 * @param { Date } 指标日期
 */
export const getDataSyncex = (
  Type: InType,
  Date?: string
): Promise<AxiosResponse<{ Type: InType; DATA: InHESData[] }>> =>
  HSExtendInterface({
    url: "/api/dataSyncex",
    method: "post",
    data: {
      data: {
        Type: Type,
        Date: Date,
      },
      token: "@#$dsjfld1sa%d#$3%Ds0d9fB",
      scenesNo: "Quota",
      uploadId: "admin",
    },
  });
/**
 * 指标查询-产量
 * @param StartDate 指标开始时间
 * @param EndDate 指标结束时间
 * @returns 
 */
export const getDataSyncexCL = (
  StartDate: string,
  EndDate: string
): Promise<AxiosResponse<{ Type: InType; DATA: InHESData[] }>> =>
  HSExtendInterface({
    url: "/api/dataSyncex",
    method: "post",
    data: {
      data: {
        Type: "产量",
        StartDate: StartDate,
        EndDate: EndDate,
      },
      token: "@#$dsjfld1sa%d#$3%Ds0d9fB",
      scenesNo: "Quota",
      uploadId: "admin",
    },
  });
/** 获取时序图列表数据 */
export const getDapingList = (dataObj: { day?: string; factory_id?: string }): Promise<AxiosResponse<{ data: InPlanDevoce }>> =>
  dapingApi({
    url: "/api/v1/daping/device",
    method: "get",
    params: {
      ...dataObj,
    },
  });
